CFLAGS ?=-g -Wall -O0

pwddir = $(PWD)
libdir = $(pwddir)/lib
buidir = $(pwddir)/build
pacdir = $(pwddir)/package
incdir = $(pwddir)/include
bindir = $(buidir)/bin
objdir = $(buidir)/obj

$(shell test -d $(libdir) || mkdir $(libdir))
$(shell test -d $(buidir) || mkdir $(buidir))
$(shell test -d $(bindir) || mkdir $(bindir))
$(shell test -d $(objdir) || mkdir $(objdir))

objects=main.o click.o user_operation.o guess_number.o file_operation.o core.o
OBJS = $(addprefix $(objdir)/,$(objects))

$(bindir)/$(GAMENAME) : $(OBJS)
	$(CC) $(OBJS) $(CFLAGS) -o $(bindir)/game
$(objdir)/main.o : main.c include/user_operation.h include/file_operation.h include/core.h 
	gcc -o $(objdir)/main.o -I include -c main.c -Wall
$(objdir)/%.o : $(pacdir)/%.c
	gcc -c -I$(incdir) $^ $(CFLAGS) -o $@
clean :
	rm -r $(objdir)
